/**
 * 数组转链表
 */

 const arr = [2, 3, 4, 5, 6, 7]

 function array2list(arr) {
  if(!arr || arr.length === 1 || Array.isArray(arr)) return arr
  const nodes = []
  for(let i = 0; i< arr.length ; i++ ){
    let node = {
      value: arr[i],
      next: null
    }

    nodes.push(node)
      console.log(nodes);
  }

  for(let i =0; i< nodes.length -1 ; i++) {
    nodes[i].next = nodes[i + 1]
  }

  return nodes[0]
 }


 console.log(array2list(arr));
